home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 2003 March / DPPCPRO0303.ISO / Components / Connector for iCat Commerce Online / data1.cab / Program_Executable_Files / iCat.jar / iCat / iCatBuilt.class (.txt) < prev    next >
Encoding:
Java Class File  |  1998-11-13  |  4.9 KB  |  144 lines

  1. package iCat;
  2.  
  3. import com.netobjects.nfc.api.CStringArray;
  4. import com.netobjects.nfc.api.ComponentApp;
  5. import com.netobjects.nfc.api.DAssetManager;
  6. import com.netobjects.nfc.api.DDrawPicture;
  7. import com.netobjects.nfc.api.DFile;
  8. import com.netobjects.nfc.api.DImage;
  9. import com.netobjects.nfc.api.DLayout;
  10. import com.netobjects.nfc.api.DMessageBox;
  11. import com.netobjects.nfc.api.DRect;
  12. import com.netobjects.nfc.api.DSite;
  13. import com.netobjects.nfc.api.DSize;
  14. import com.netobjects.nfc.api.IDInspector;
  15.  
  16. public class iCatBuilt extends ComponentApp {
  17.    String strImageFile = "";
  18.    String strStoreURL = "";
  19.    int Image;
  20.    DDrawPicture cdp;
  21.    String codebase;
  22.    DAssetManager assetMan;
  23.  
  24.    public void onCopy() {
  25.       this.assetMan.CopyAsset(this.Image);
  26.    }
  27.  
  28.    protected void finalize() {
  29.       this.assetMan.RemoveAsset(this.Image);
  30.       this.strImageFile = null;
  31.       this.strStoreURL = null;
  32.       this.cdp = null;
  33.       this.codebase = null;
  34.       this.assetMan = null;
  35.    }
  36.  
  37.    public void onUnInstall(DAssetManager var1) {
  38.    }
  39.  
  40.    public String onInstall(DAssetManager var1, String var2) {
  41.       this.assetMan = var1;
  42.       this.codebase = var2;
  43.       this.strImageFile = this.codebase + "\\iCatBuilt.gif";
  44.       return "iCat Built";
  45.    }
  46.  
  47.    public void onInspect(CStringArray var1, CStringArray var2) {
  48.       var1.Set("Store URL");
  49.       var2.Set("String");
  50.       var1.Set("Image");
  51.       var2.Set("Image");
  52.    }
  53.  
  54.    public String PropertyListener(String var1, String var2, int var3, int var4, IDInspector var5) {
  55.       if (var3 == 1) {
  56.          if (var1.compareTo("Store URL") == 0) {
  57.             return this.strStoreURL;
  58.          }
  59.  
  60.          if (var1.compareTo("Image") == 0) {
  61.             return Integer.toString(this.Image);
  62.          }
  63.       } else {
  64.          if (var1.compareTo("Store URL") == 0) {
  65.             this.strStoreURL = var2;
  66.             if (this.strStoreURL.length() != 0) {
  67.                this.writeiCatFile(this.strStoreURL);
  68.             }
  69.          } else if (var1.compareTo("Image") == 0) {
  70.             this.assetMan.RemoveAsset(this.Image);
  71.             this.Image = Integer.parseInt(var2, 10);
  72.             this.strImageFile = this.assetMan.GetAssetLocation(this.Image, 1, 1);
  73.             DImage var6 = new DImage();
  74.             var6.setImageFile(this.strImageFile);
  75.             DSize var7 = var6.getSize();
  76.             this.cdp.SetSize(var7.getWidth(), var7.getHeight());
  77.             this.cdp.setImageFile(this.assetMan.GetAssetLocation(this.Image, -1, 1));
  78.          }
  79.  
  80.          this.cdp.Invalidate(true);
  81.       }
  82.  
  83.       if (var5 != null) {
  84.          var5.OnPropertyChanged(-1);
  85.       }
  86.  
  87.       return "";
  88.    }
  89.  
  90.    public void onDrop(DLayout var1, DRect var2, int var3) {
  91.       if (var3 == 1) {
  92.          this.cdp = new DDrawPicture();
  93.          this.cdp.SetPositionRect(var2.getLeft(), var2.getTop(), var2.getRight(), var2.getBottom());
  94.          this.cdp.SetStyle(1, 1);
  95.          this.cdp.setStretch(2);
  96.          this.cdp.setUsePictureText(false);
  97.          DImage var4 = new DImage();
  98.          var4.setImageFile(this.strImageFile);
  99.          DSize var5 = var4.getSize();
  100.          this.cdp.SetSize(var5.getWidth(), var5.getHeight());
  101.          this.cdp.setImageFile(this.strImageFile);
  102.          var1.AddObject(this.cdp);
  103.       }
  104.    }
  105.  
  106.    public void onPublish(DAssetManager var1, int var2) {
  107.       String var3 = "<A HREF=\"http://www.icat.com\" target=\"_top\" >";
  108.       this.cdp.setAltTag("This store was built using iCat technology.");
  109.       this.cdp.setHTMLBefore(var3);
  110.       this.cdp.setHTMLAfter("</A>");
  111.       if (this.strStoreURL.length() == 0) {
  112.          DMessageBox var4 = new DMessageBox();
  113.          var4.Warning("The Store URL property of the iCatBuilt component MUST be filled in.\r\nPlease enter this value and republish your site.\r\n");
  114.       }
  115.  
  116.    }
  117.  
  118.    public void writeiCatFile(String var1) {
  119.       DSite var2 = new DSite();
  120.       String var3 = var2.getName();
  121.       DFile var4 = new DFile();
  122.       if (var4.Open(this.codebase + "\\iCatInfo\\" + var3 + ".txt", 4097)) {
  123.          var4.Seek(0, 0);
  124.          var4.WriteString(var1, -1);
  125.          var4.Close();
  126.       } else {
  127.          DMessageBox var5 = new DMessageBox();
  128.          var5.Warning("The file (" + this.codebase + "iCatInfo\\" + var3 + ".txt) could not be created.\r\n" + "Without this file the iCat components will not publish correctly.\r\n");
  129.       }
  130.    }
  131.  
  132.    public void removeAsset(int var1) {
  133.       if (var1 != 0) {
  134.          this.assetMan.RemoveAsset(var1);
  135.       }
  136.  
  137.    }
  138.  
  139.    private void debug(String var1) {
  140.       DMessageBox var2 = new DMessageBox();
  141.       var2.Warning(var1 + "\r\n");
  142.    }
  143. }
  144.